// pages/person/personEditInfo.js
const httpUtils = require('../../utils/httpUtils')
const ui = require('../../utils/ui')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    username: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
this.setData({
  username: options.name
})
  },
  //保存信息
  saveInfo() {
    let obj2 = {
      method: 'PUT',
      url: '/user/'+wx.getStorageSync('USERDATA').platformId,
      data: {
        nickName: this.data.username
      }
    }
    httpUtils.request(obj2).then(res => {
      wx.showToast({
        title: '修改成功',
        icon: 'success',
        duration: 2000,
        mask: true,
        success: function() {
          setTimeout(function() {
            wx.navigateBack({
              delta: 0,
            });
          }, 1500)
        }
      });
    }).catch(err => {
      console.log('ERROR')
    });
  }
})